package editor.headers;

import javax.swing.*;
import java.awt.event.ComponentListener;
import java.awt.event.ComponentEvent;
import java.awt.*;

/**
 * @author Neil Dickson
*/
public abstract class HeaderComponent extends JComponent implements ComponentListener {
	protected final Header header;
	protected HeaderComponent(Header header) {
		this.header = header;
	}
	public abstract int getType();
	public abstract void doLayout(int width);
	public abstract int getMinWidth();
	public void componentResized(ComponentEvent e) {
		if (((Component)e.getSource()).getHeight()!=getHeight() || getMinWidth()>header.getWidth()- Header.MARGIN*2) {
			header.doFullLayout();
		}
		else {
			doLayout(header.getWidth());
		}
	}
	public void componentMoved(ComponentEvent e) {}
	public void componentShown(ComponentEvent e) {}
	public void componentHidden(ComponentEvent e) {}
}
